#include "ScheduleItem.h"

ScheduleItem::ScheduleItem( int id, int program, int faculty, int room, int course )
	: QGraphicsObject()
	, mId( id )
	, mProgram( program )
	, mFaculty( faculty )
	, mRoom( room )
	, mCourse( course )
{
	boundRect = QRectF( 0, 0, 0, 0 );

	mPeriods << new Period( this, 1100, 1250, MONDAY );
	connect( mPeriods.at( 0 ), SIGNAL( selected( Period* ) ), this, SLOT( selectPeriod( Period* ) ) );
	connect( mPeriods.at( 0 ), SIGNAL( activated( Period* ) ), this, SLOT( activatePeriod( Period* ) ) );
}

ScheduleItem::~ScheduleItem()
{
}

void
ScheduleItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
}

void
ScheduleItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent* event )
{
}

void
ScheduleItem::mousePressEvent( QGraphicsSceneMouseEvent* event )
{
}

void
ScheduleItem::selectPeriod( Period* period )
{
	for( int i = 0; i < mPeriods.size(); i++ )
	{
		mPeriods.at( i )->setSelection( true );
		mPeriods.at( i )->update();
	}
}

void
ScheduleItem::activatePeriod( Period* period )
{
	PeriodDialog p( period );
	p.exec();
}